﻿<Page
    x:Name="pageRoot"
    x:Class="BootyBay.PrivateStoreApp.MainPage"
    DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Self}}"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:BootyBay.PrivateStoreApp"
    xmlns:control="using:BootyBay.PrivateStoreApp.Controls"
    xmlns:common="using:BootyBay.PrivateStoreApp.Common"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    KeyDown="pageRoot_KeyDown"
    >
    <Page.TopAppBar>
        <AppBar BorderThickness="1" BorderBrush="#99205B96" Margin="0,-2,0,0">
            <Grid Height="105" Background="#99205B96">
                <StackPanel Orientation="Horizontal">
                    <Button Margin="27,0,0,0" Content="主页" Background="#77ACE1" BorderThickness="0" Style="{StaticResource AppsPage_Home_ButtonStyle}" x:Name="btn_Home" Click="btn_Home_Click"></Button>
                    <Button Margin="10,0,0,0" Content="你的应用" Background="#77ACE1" BorderThickness="0" Style="{StaticResource AppsPage_YourApps_ButtonStyle}" x:Name="btn_AppList" Click="btn_AppList_Click"></Button>
                </StackPanel>
            </Grid>
        </AppBar>
    </Page.TopAppBar>
    <Page.Resources>
        <x:String x:Key="ChevronGlyph">&#xE26B;</x:String>
        <common:RecommendListToCategoryListConverter x:Key="RecommendListToCategoryListConverter"></common:RecommendListToCategoryListConverter>
    </Page.Resources>

    <!--
        此网格充当页的根面板。
    -->
    <Grid>
        <Grid.ChildrenTransitions>
            <TransitionCollection>
                <EntranceThemeTransition/>
            </TransitionCollection>
        </Grid.ChildrenTransitions>
        <Grid.Background>
            <ImageBrush ImageSource="Images/bg.png"></ImageBrush>
        </Grid.Background>
        <Hub SectionHeaderClick="Hub_SectionHeaderClick" Margin="20,0,0,0" RequestedTheme="Light">
            <Hub.Header>
                <!-- 后退按钮和页标题 -->
                <Grid Margin="0,-25,0,0">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="25"/>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="25"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>
                    <Image Grid.Column="0" Source="images/HomeLogo.jpg" Width="57" Height="57"></Image>
                    <TextBlock x:Name="pageTitle" Text="{StaticResource AppName}" Style="{StaticResource HomePage_HeaderTextBlockStyle}" Grid.Column="2" 
                        IsHitTestVisible="false" TextWrapping="NoWrap" VerticalAlignment="Center"/>
                    <ProgressRing x:Name="progressRing_LoadInfo" Grid.Column="4" Height="50" Width="50" HorizontalAlignment="Center" VerticalAlignment="Center"></ProgressRing>
                </Grid>
            </Hub.Header>
            <HubSection Width="795" x:Name="grd_HomePage" >
                <DataTemplate>
                    <control:MainPageFlipViewControl Margin="-25,0,0,0"></control:MainPageFlipViewControl>
                </DataTemplate>
            </HubSection>
            <HubSection DataContext="{Binding appCategoriesPageVM}" Header="类别" Style="{StaticResource HomePage_CategoriesTitle_TextStyle}">
                <DataTemplate>
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="*" />
                        </Grid.RowDefinitions>
                        <GridView x:Name="ItemListView" Grid.Row="0" ItemsSource="{Binding AppCategories}" Height="{Binding ElementName=grd_HomePage,Path=ActualHeight,Converter={StaticResource RecommendListToCategoryListConverter}}" Padding="0,0,-45,0"
                              AutomationProperties.AutomationId="ItemListView"
                              AutomationProperties.Name="Items In Group"
                              SelectionMode="None"
                              IsSwipeEnabled="false"
                              ItemContainerStyle="{StaticResource StoreFrontTileStyle}"
                              IsItemClickEnabled="True"
                              ItemClick="ItemListView_ItemClick"
                              >
                            <GridView.ItemTemplate>
                                <DataTemplate>
                                    <Border>
                                        <TextBlock TextWrapping="Wrap" MinWidth="204" Text="{Binding Value}" Foreground="#333333"/>
                                    </Border>
                                </DataTemplate>
                            </GridView.ItemTemplate>
                        </GridView>
                    </Grid>
                </DataTemplate>
            </HubSection>
            <HubSection IsHeaderInteractive="True"
                        DataContext="{Binding applistPageVM}"
                        x:Uid="Section3Header"
                        Padding="40,40,40,32"
                        Header="推荐"
                        Style="{StaticResource HomePage_CategoriesTitle_TextStyle}"
                        >
                <DataTemplate>
                    <GridView 
                              ItemsSource="{Binding RecommendAppData}"
                              ItemTemplate="{StaticResource AppListItemTemplate}"
                              ItemContainerStyle="{StaticResource HomePage_AppListItemStyle}"
                              SelectionMode="None"
                              IsSwipeEnabled="false"
                              IsItemClickEnabled="True"
                              ItemClick="itemGridView_ItemClick">
                    </GridView>

                    <!--<GridView x:Name="itemGridView"
                              ItemsSource="{Binding RecommendAppData}"
                              Margin="-9,-14,0,0"
                              AutomationProperties.AutomationId="ItemGridView"
                              AutomationProperties.Name="Items In Group"
                              ItemTemplate="{StaticResource AppListItemTemplate}"
                              SelectionMode="None"
                              IsSwipeEnabled="false"
                              IsItemClickEnabled="True"
                              ItemClick="itemGridView_ItemClick"
                              >
                    </GridView>-->
                </DataTemplate>
            </HubSection>

        </Hub>
        <Border Background="#FFFFFF"  BorderBrush="#669ACD" BorderThickness="2" Width="268" Height="30" Margin="0,70,40,0" HorizontalAlignment="Right" VerticalAlignment="Top">
            <Grid VerticalAlignment="Center" Height="30">
                <TextBox x:Name="txtSearch" Background="#00FFFFFF" BorderThickness="0" Width="268" Height="30" Foreground="#333333" FontSize="14" Text="搜索应用" VerticalAlignment="Center" Padding="5,7,30,0" GotFocus="txtSearch_GotFocus" LostFocus="txtSearch_LostFocus"></TextBox>
                <Border HorizontalAlignment="Right" Height="40" Width="30" Background="#FFFFFF" BorderThickness="0" Margin="0,0,-2,0">
                    <Button x:Name="btn_Search" Margin="0,-10,0,0" Click="btn_Search_Click" Style="{StaticResource SearchResultsPage_Search_ButtonStyle}" BorderThickness="0"></Button>
                </Border>
            </Grid>
        </Border>
    </Grid>
</Page>
